<?php $this->load->view('partial/head'); ?>

<h2>Detail Pesanan</h2>

<form method="post" action="<?= base_url()."index.php/kasir/proses_bayar" ?>">	
	<input type="hidden" name="id_pesanan" value="<?=$pesanan['id_pesanan']?>" />
	<table cellpadding="10">
		<tr>
			<td>Waktu Pesan</td>
			<td><input type="hidden" name="waktu_pesan" value="<?=date('d M Y H:i', strtotime($pesanan['waktu_pesan']))?>" /><?=date('d M Y H:i', strtotime($pesanan['waktu_pesan']))?></td>
		</tr>
		<tr>
			<td>No. Meja</td>
			<td><input type="hidden" name="no_meja" value="<?= $pesanan['no_meja'] ?>" /><?= $pesanan['no_meja'] ?></td>
		</tr>
		<tr>
			<td>Detail Pesanan</td>
			<td>
				<?php $jum = 0;
				foreach($pesanan['detail'] as $detail){ 
					$kali = $detail['harga'] * $detail['jumlah']; ?>
					<b><?=$detail['nama']?> (<?=$detail['jumlah']?>)</b> |
					<?=$detail['harga']?> x <?=$detail['jumlah']?> = <?=$kali?>
					<br/>
				<?php $jum = $jum + $kali; } ?>
			</td>
		</tr>
		<tr>
			<td>Jumlah Pesanan</td>
			<td><input type="hidden" name="jumlah_pesanan" value="<?=$jum?>">Rp. <?=$jum?>,-</td>
		</tr>
		<tr>
			<td>Pajak</td>
			<td><?php $pajak = 0.1 * $jum; ?><input type="hidden" name="pajak" value="<?=$pajak?>">Rp. <?=$pajak?>,-</td>
		</tr>
		<tr>
			<td>Diskon</td>
			<td><?php $diskon = ($jum > 500000 ? 0.05 * $jum : 0); ?><input type="hidden" name="diskon" value="<?=$diskon?>">Rp. <?=$diskon?>,-</td>
		</tr>
		<tr>
			<td>Jumlah Bayar</td>
			<td><?php $jum_bayar = $jum + $pajak - $diskon; ?><input type="hidden" name="jumlah_bayar" value="<?=$jum_bayar?>">Rp. <?=$jum_bayar?>,-</td>
		</tr>
		<tr>
			<td>Status</td>
			<td><font color="<?=$status[$pesanan['status']]['warna']?>"><?=$status[$pesanan['status']]['nama']?></font></td>
		</tr>
		<tr>
			<td>Pelayan yg entri Pesanan</td>
			<td><?=$pesanan['pelayan']?></td>
		</tr>
		<?php if($is_history){ ?>
			<tr>
				<td></td>
				<td><a href="<?=$_SERVER['HTTP_REFERER']?>"><input type="button" value="Kembali" /></a></td>
			</tr>
		<?php }else{ ?>
			<tr>
				<td>Pembayaran</td>
				<td>
					<?php if($pesanan['status'] == STATUS_SUDAH_SELESAI_DIMASAK){ ?>
						<input type="submit" value="Update status Bayar & Cetak Nota" />
					<?php }else{ ?>
						<font color="red">Pembayaran dapat dilakukan setelah status pesanan selesai dimasak</font><br/>
						<a href="<?=$_SERVER['HTTP_REFERER']?>"><input type="button" value="Kembali" /></a>
					<?php } ?>
				</td>
			</tr>
		<?php } ?>
	</table>
</form>